#!/bin/sh
# auther: JasonYin
# email: y1053419035@qq.com
# blog: https://www.cnblogs.com/yinzhengjie/

# 创建nginx子配置文件目录
mkdir -pv /etc/nginx/conf.d

# 创建nginx的游戏配置文件
cat > /etc/nginx/conf.d/games.conf <<EOF
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/bird/;
    server_name   game01.oldboyedu.com;
}
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/pinshu/;
    server_name   game02.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/tanke/;
    server_name   game03.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/chengbao/;
    server_name   game04.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/motuo/;
    server_name   game05.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/liferestart/;
    server_name   game06.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/huangjinkuanggong/;
    server_name   game07.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/feijidazhan/;
    server_name   game08.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/zhiwudazhanjiangshi/;
    server_name   game09.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/xiaobawang/;
    server_name   game10.oldboyedu.com;
}
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/pingtai/;
    server_name   game11.oldboyedu.com;
}

server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/dayu/;
    server_name   game12.oldboyedu.com;
}
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/maliao/;
    server_name   game13.oldboyedu.com;
}
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/menghuanmonizhan/;
    server_name   game14.oldboyedu.com;
}
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/qieshuiguo/;
    server_name   game15.oldboyedu.com;
}
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/wangzhezhicheng/;
    server_name   game16.oldboyedu.com;
}
server {
    listen        ${IP:-0.0.0.0}:${PORT:-80};
    root          ${DATA_DIR:-/usr/local/nginx/html}/zhiwuVSjiangshi/;
    server_name   game17.oldboyedu.com;
}
EOF


ln -svf /dev/stdout /var/log/nginx/access.log
ln -svf /dev/stderr /var/log/nginx/error.log

nginx

tail -f "/etc/hosts"

# if [ -n "$1" ];then
#    echo root:$1 | chpasswd
# elif [ -n "$OLDBOYEDU_ADMIN" ]; then
#    echo root:$OLDBOYEDU_ADMIN | chpasswd
# else 
#    echo root:"123" | chpasswd
# fi
# 
# ssh-keygen -A
# 
# /usr/sbin/sshd -D
